//
//  LCImageViewController.m
//  BJS151148_ TeamProject_Travel
//
//  Created by lanou3g on 16/3/23.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "LCImageViewController.h"
#import "LCImageViewCell.h"
@interface LCImageViewController ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>

@end

@implementation LCImageViewController

//-(void)loadView
//{
//    self.view = self.aView;
//    
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    self.aView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.aView];
    self.aImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 70, 60, 60)];
    self.aImageView.backgroundColor = [UIColor brownColor];
    self.aImageView.layer.cornerRadius = 4;
    self.aImageView.layer.masksToBounds = YES;
    
    [self.aView addSubview:self.aImageView];
    self.aLbael = [[UILabel alloc]initWithFrame:CGRectMake(self.aImageView.frame.size.width+10, 75, self.view.frame.size.width - 200, 25)];
    self.aLbael.backgroundColor = [UIColor brownColor];
    [self.view addSubview:self.aLbael];
    
    self.bLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.aImageView.frame.size.width+10, self.aLbael.frame.size.height + 80, self.aLbael.frame.size.width - 50, 25)];
    self.bLabel.backgroundColor = [UIColor brownColor];
    [self.view addSubview:self.bLabel];
    self.aLbael.layer.cornerRadius = 4;
    self.aLbael.layer.masksToBounds = YES;
    self.bLabel.layer.cornerRadius = 4;
    self.bLabel.layer.masksToBounds = YES;
    
    
    self.aButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.aButton.frame = CGRectMake(5, self.aImageView.frame.size.height + 80, self.view.frame.size.width / 2 - 10, 30);
    self.aButton.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.aButton];
    self.aButton.layer.cornerRadius = 4;
    self.aButton.layer.masksToBounds = YES;
    
    self.bButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.bButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width / 2 + 5, self.aImageView.frame.size.height + 80, self.aButton.frame.size.width, 30);
    self.bButton.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.bButton];

    [self.aButton setTitle:@"关注" forState:(UIControlStateNormal)];
    [self.bButton setTitle:@"私信" forState:(UIControlStateNormal)];
    self.bButton.layer.cornerRadius = 4;
    self.bButton.layer.masksToBounds = YES;
    
    
    
    
    
    
    self.segmentCon = [[UISegmentedControl alloc]initWithItems:@[@"游记",@"喜欢"]];
    self.segmentCon.frame = CGRectMake(5, self.bButton.frame.size.height + 150, self.view.frame.size.width - 10, 40);
    self.segmentCon.layer.cornerRadius = 4;
    self.segmentCon.layer.masksToBounds = YES;
    self.segmentCon.backgroundColor = [UIColor yellowColor];
    
    self.aScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.segmentCon.frame), [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - CGRectGetMaxY(self.segmentCon.frame))];
    self.aScrollView.backgroundColor = [UIColor greenColor];
    self.aScrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 2, CGRectGetHeight(self.aScrollView.frame));
    [self.view addSubview:self.aScrollView];

    
    [self.view addSubview:self.segmentCon];
    
    
    self.aTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0 , self.view.frame.size.width, self.view.frame.size.height -  CGRectGetMaxY(self.segmentCon.frame)) style:(UITableViewStyleGrouped)];
    
//    self.aTableView.backgroundColor = [UIColor brownColor];
    [self.aScrollView addSubview:self.aTableView];
    self.aTableView.delegate = self;
    self.aTableView.dataSource =self;
    
    [self.aTableView registerNib:[UINib nibWithNibName:@"LCImageViewCell"  bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"cell"];
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 3;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 200;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}


    
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
//        self.automaticallyAdjustsScrollViewInsets = NO;

    static NSString *ID = @"cell";
    LCImageViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell ==nil) {
        cell = [[LCImageViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:ID];
    }
    return cell;
}









@end
